import React from 'react';
import { find } from 'lodash';
import { Breadcrumb } from 'antd';
import styles from './index.less';

export default function Bread({keyPath = [], menu = [], style = {}}) {
    const [child, parent] = keyPath;
    const { children, name } = find(menu, ['code', parent || child]) || {};
    const { name: keyName } = find(children || [], ['code', child]) || {};
    return (
        <div className={styles.breadcrumb} style={style}>
            <Breadcrumb>
                <Breadcrumb.Item>{name}</Breadcrumb.Item>
                {parent ? <Breadcrumb.Item>{keyName}</Breadcrumb.Item> : null}
            </Breadcrumb>
        </div>
    );
}
